package la.iok.hzsvn.lewin.movie.service;

import la.iok.hzsvn.lewin.movie.anno.MovieEncryptValidation;
import la.iok.hzsvn.lewin.movie.core.Token;
import la.iok.hzsvn.lewin.movie.entity.MovieEncryptCode;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * 配置为不需要验证的话，直接返回剧本密钥
 */
@SpringBootTest
@MovieEncryptValidation(validateBeforeGetMovieEncoder = "false")
public class MovieEncryptCodeServiceTestsWithoutValidationEnabled {
    @Autowired
    private MovieEncryptCodeService movieEncryptCodeService;
    @Test
    public void testMovieEncryptCode(){
        Long movieId = 2341L;
        movieEncryptCodeService.delete("movieId",movieId);
        MovieEncryptCode code = movieEncryptCodeService.movieEncryptCode(new Token(),movieId);
        Assertions.assertNull(code);
        MovieEncryptCode code2 = movieEncryptCodeService.save(movieId);
        code = movieEncryptCodeService.movieEncryptCode(new Token(),movieId);
        Assertions.assertEquals(code,code2);
        movieEncryptCodeService.delete(code.getId());
    }
}
